<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Ajax-实现异步请求-JSON</title>
  <script src="js/jquery-3.7.1.js"></script>
</head>
<body>
<h1>Ajax-实现异步请求-JSON</h1>
<button id="btn1">用户手动拼接字符串</button>
<button id="btn2">GSON工具实现</button>
<p>响应结果：<span id="jg"></span></p>

<script>
  $("#btn1").click(function(){
    $.ajax({
      url:"json.do",
      type:"post",
      //把 json 字符串转换为对应的 JavaScript 对象
      dataType:"json",
      success:function(data){
        console.log(data);
      },
    });
  });

</script>
</body>
</html>